<!-- 帆软BI及报表展示 -->
<template>
  <div class="link-home">
    <div id="iframe-container" >
      <iframe :src="link" scrolling="auto" frameborder="0" id="iframe" ></iframe>
    </div>
  </div>
</template>

<script>
//import NProgress from 'nprogress'
import axios from 'axios'
export default {
  data() {
      return {
        title: "",
        link: "",
      }
   },
  mounted() {
    // this.getAjaxSSO();
    // var s = "http://192.168.75.35:8082/webroot/decision/login/cross/domain?fine_username=qiuyj&fine_password=qyj123456&validity=-1";
    // this.fetchJsonp();
    // let iframe = document.getElementById('iframe')
    // alert(this.$route.meta.title)
    // this.title = this.$route.meta.title;
    // this.link = this.$route.meta.link;

    // this.initData();
   
  },
  // created(){
  //   this.fetchJsonp();
  // },
  watch: {
    // $route: function (to) {
    //   // alert(to.path)
    //   if(to.path == '/externalLink_SjAnalysis_sj')
    //   {
    //      this.fetchJsonp();
    //   }
        // this.title = this.$route.meta.title;
        // this.link = this.$route.meta.link;
        // var  TOKEN = window.sessionStorage.getItem('token')
        // if(this.title =="天网智慧平台")
        // {
        //  this.link = this.link+"?token="+TOKEN
        // }
     
    // }
  },
  activated(){
      let platform = navigator.userAgent;
      if (platform.indexOf("Electron") == -1) { //web端时跳转回上一页
        this.link = ''
        this.$router.back(-1)
        return
      }else{
        this.fetchJsonp(); 
      }
    // let title = this.$route.meta.title;
    // if(title == '数据自助分析'){
         
    // }
  },
  methods: {
    // initData(){
    //       var fineLinks = localStorage.getItem("fineLinks")
    //       fineLinks = fineLinks?JSON.parse(fineLinks):[]   
    //       //存入缓存中
    //       var jsonObj = {title:this.title,link:this.link,isShow:true};
    //       fineLinks.map(item =>{
    //           if(item.title === this.title)
    //           {
    //             item.isShow = true;
    //           }else{
    //             item.isShow = false;
    //           }
    //       });
    //       var filterA = fineLinks.filter(item => item.title == this.title);
    //       if(filterA.length==0)
    //       {
    //          fineLinks.push(jsonObj)
    //       }
    //       this.fineLinks = fineLinks;
    //       localStorage.setItem("fineLinks",JSON.stringify(fineLinks))
    // },
     fetchJsonp(){
        // var body = document.getElementsByTagName('body')[0];
        // //插入一个script
        // var script = document.createElement('script');
        // script.setAttribute('src',url);
        // body.appendChild(script);
        // alert(111)
        // var user = sessionStorage.getItem("accNo");
        var token = sessionStorage.getItem("token");
        // this.initWebSocket()
        var params = {
            access_token: token,
            other_header: 'other_header'
        };
        var paramstr = "access_token="+token;

        //Add authentication headers in URL
        // var url = ["http://192.168.75.35:8082/webroot/decision", paramstr].join('?');

        //Open window
        // let platform = navigator.userAgent;
        // if (platform.indexOf("Electron") != -1) {
          
        //   this.link = "http://192.168.75.35:8082/webroot/decision?token="+encodeURIComponent(token);

        // } else {
        //    window.open("http://192.168.75.35:8082/webroot/decision?token="+encodeURIComponent(token));
        // }
         this.link = "http://192.168.75.35:8082/webroot/decision?token="+encodeURIComponent(token);

        
    }
  }
}
</script>
<style lang="less" scoped>
.link-home{
  width: 100%;
  height: 100%;
}
#iframe-container{
  width: 100%;
  height: 100%;
}
#iframe{
  width: 100%;
  height: 100%;
}
</style>